import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { WorkshopVO, WorkshopForm, WorkshopQuery } from '@/api/wmscloud/workshop/types';

/**
 * 查询车间列表
 * @param query
 * @returns {*}
 */

export const listWorkshop = (query?: WorkshopQuery): AxiosPromise<WorkshopVO[]> => {
  return request({
    url: '/wmsCloud/workshop/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询车间详细
 * @param workshopId
 */
export const getWorkshop = (workshopId: string | number): AxiosPromise<WorkshopVO> => {
  return request({
    url: '/wmsCloud/workshop/' + workshopId,
    method: 'get'
  });
};

/**
 * 新增车间
 * @param data
 */
export const addWorkshop = (data: WorkshopForm) => {
  return request({
    url: '/wmsCloud/workshop',
    method: 'post',
    data: data
  });
};

/**
 * 修改车间
 * @param data
 */
export const updateWorkshop = (data: WorkshopForm) => {
  return request({
    url: '/wmsCloud/workshop',
    method: 'put',
    data: data
  });
};

/**
 * 删除车间
 * @param workshopId
 */
export const delWorkshop = (workshopId: string | number | Array<string | number>) => {
  return request({
    url: '/wmsCloud/workshop/' + workshopId,
    method: 'delete'
  });
};
